package com.itjiange.shopsystem.controller;

import com.itjiange.shopsystem.adapter.Login3rdTarget;
import com.itjiange.shopsystem.pojo.UserInfo;
import com.itjiange.shopsystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户接口
 *
 * @author ItJiange
 * @date 2023/11/18
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @Autowired
    private Login3rdTarget login3rdTarget;

    @GetMapping("/gitee")
    public String gitee(String code, String state) {
        return login3rdTarget.loginByGitee(code, state);
    }

    @PostMapping("/login")
    public String login(String account, String password) {
        return userService.login(account,password);
    }

    @PostMapping("/register")
    public String register(@RequestBody UserInfo userInfo) {
        return userService.register(userInfo);
    }
}
